package day14;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author du.senlin
 * @Title:
 * @Description:
 * @date 2020/5/26 9:42
 */
public class Book {
    // 书名
    private String name;
    // 价格
    private double price;
    // 折扣
    private double discount;
    // 库存
    private int stock ;
    private static int stock2 =2;

    public Book(String name, double price, double discount, int stock) {
        this.name = name;
        this.price = price;
        this.discount = discount;
        this.stock = stock;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getDiscount() {
        return discount;
    }

    public void setDiscount(double discount) {
        this.discount = discount;
    }

    public int getStock() {
        return stock;
    }

    public void setStock(int stock) {
        this.stock = stock;
    }

    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", price=" + price +
                ", discount=" + discount +
                ", stock=" + stock +
                '}';
    }

    public static void main(String[] args) {
//        Book book = new Book("地理", 10.00, 0.98, 100);
//        System.out.println(book.toString());
//        book.setPrice(9.00);
//        System.out.println("变更价格后："+book.toString());

        AtomicInteger atomicInteger =new AtomicInteger(1);

        int i = atomicInteger.incrementAndGet();
        System.out.println(i);

        int curr = stock2;
        if(curr!=stock2){

        }
        // compare and swap
        // curr=1
        // read :1  store :1
        // store:curr !curr=store
        // lockandcmpchg

        System.out.println("模拟内存泄漏");
        ThreadLocal<Byte[]> localVariable = new ThreadLocal<Byte[]>();
        localVariable.set(new Byte[4096 * 1024]);// 为线程添加变量

    }





}
